package com.ruoyi.system.service.impl;


import com.ruoyi.system.domain.entity.SmartReservation;
import com.ruoyi.system.domain.generation.*;
import com.ruoyi.system.domain.moneyentity.SmartCarMonthlyCardRelations;
import com.ruoyi.system.domain.moneyentity.SmartWhitelist;
import com.ruoyi.system.mapper.SmartSystemConfigurationMapper;
import com.ruoyi.system.service.ISmartSystemConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * SmartSystemConfigurationServiceImpl
 *系统设置实现类
 * @author life.
 * @date 2025/3/21
 */
@Service
public class SmartSystemConfigurationServiceImpl implements ISmartSystemConfigurationService {
    @Autowired
    private SmartSystemConfigurationMapper smartSystemConfigurationMapper;

    /**
     * 系统设置
     */
    /**
     * 月卡收费规则（查询）
     * @param scBindingId 绑定 ID
     * @return
     */
    @Override
    public List<SmartCarMonthlyCardRelations> selectAllSmartCarMonthlyCardRelations(  Long scBindingId,
                                                                                      Date scActivationDate,
                                                                                     Date scExpiryDate,
                                                                                      Long scIsActive) {
        return smartSystemConfigurationMapper.selectAllSmartCarMonthlyCardRelations(scBindingId,scActivationDate,scExpiryDate,scIsActive);
    }

    /**
     * 上下架月卡
     * @param scBindingId 月卡绑定 ID
     * @param scIsActive 新的上架下架状态值
     * @return
     */
    @Override
    public int updateScIsActiveByMonthlyCardBindingId(Long scBindingId, Long scIsActive) {
        return smartSystemConfigurationMapper.updateScIsActiveByMonthlyCardBindingId(scBindingId,scIsActive);
    }

    /**
     * 月卡各项规则的修改
     * @param request 修改请求对象
     * @return
     */
    @Override
    public int updateMonthlyCardInfo(UpdateMonthlyCardInfoRequest request) {
        return smartSystemConfigurationMapper.updateMonthlyCardInfo(request);
    }
    /**
     * 月卡各项规则的增加
     * @param request 增加请求对象
     * @return
     */
    @Override
    public int insertMonthlyCardInfo(IncreaseMonthlyCardInfoRequest request) {
        int rows1 = smartSystemConfigurationMapper.insertMonthlyCardRelations(request);
        int rows2 = smartSystemConfigurationMapper.insertChargingRule(request);
        return rows1 + rows2;
    }

    /**
     * 会员收费规则（查询）
     * @param scWhitelistId 会员 ID
     * @return
     */
    @Override
    public List<SmartWhitelist> selectAllSmartWhitelist(Long scWhitelistId,
                                                        Date scValidPeriodStart,
                                                        Date scValidPeriodEnd,
                                                        Long scIsActive) {
        return smartSystemConfigurationMapper.selectAllSmartWhitelist(scWhitelistId,scValidPeriodStart,scValidPeriodEnd,scIsActive);
    }

    /**
     * 上下架会员
     * @param scWhitelistId 会员 ID
     * @param scIsActive 新的上架下架状态值
     * @return
     */
    @Override
    public int updateScIsActiveByWhitelistId(Long scWhitelistId, Long scIsActive) {
        return smartSystemConfigurationMapper.updateScIsActiveByWhitelistId(scWhitelistId,scIsActive);
    }

    /**
     * 修改会员各项信息
     * @param request 修改请求对象
     * @return
     */
    @Override
    public int updateMemberInfo(UpdateWhileListInfoRequest request) {
        return smartSystemConfigurationMapper.updateMemberInfo(request);
    }

    /**
     * 会员新增
     * @param request 新增请求对象
     * @return
     */
    @Override
    public int insertMemberInfo(IncreaseWhileListInfoRequest request) {
        int whitelistRows = smartSystemConfigurationMapper.insertWhitelistInfo(request);
        int ruleRows = smartSystemConfigurationMapper.insertChargingRuleInfo(request);
        return whitelistRows + ruleRows;
    }





}